package com.stone.widget;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
//在该类中只是进行数据库和表的创建
public class MyDbHelper extends SQLiteOpenHelper{
    
	public MyDbHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
	    String sql="CREATE TABLE "+CountryCode.TABLE_NAME
	                 +" ( "
	                 +CountryCode.FIELD_ID+" INTEGER primary key autoincrement,"
	                 +CountryCode.FIELD_NAME+" TEXT,"
	                 +CountryCode.FIELD_CODE+" INTEGER)"
	                 ;
	    db.execSQL(sql);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
	   String sql="DROP TABLE IF EXISTS "+CountryCode.TABLE_NAME;
	   db.execSQL(sql);
	   onCreate(db);
	}
 
}